
using CStock;
using System;
using System.Diagnostics;
using NUnit.Framework;
using System.Collections;
using CGraph;
using System.Data;
using System.Reflection;
using CGrid;
using CTrading;
using CUtil;
namespace TestCases.UI.Chart
{
	

	/// <summary>Some simple Tests.</summary>
	/// 
	[TestFixture]
    public class SharePlotTest : TestCases.StockData.DataClassTest
	{


        ArrayList yAxisArray;
        ArrayList xAxisArray;
        protected ChartWindow chartWindow;
        IDataItem dataItem;
        public SharePlotTest()
        {
            CreateChartWithProgramContext();

        }
        protected void CreateChartWithProgramContext()
        {
            //DataClassFactory dcf = new DataClassFactory();
            //IDataItem  di = dcf.Create_TestData("test", 20000);
            int numberOfShareValues = 200;

            dataItem = this.CreateDataItem(numberOfShareValues);
            dataItem.ID = this.DataClassFactory.StockObjectBase.ID;
            this.programContext.TradeEconomy.Portfolio_Selected.DataItem_Selected = dataItem;

            this.programContext.TradeEconomy.Portfolio_Selected.DataItem_Selected.DataClass = dataItem.DataClass;

            ResetChartWindow();

        }
        protected void ResetChartWindow()
        {
            chartWindow = new ChartWindow();
            chartWindow.Initialize_ChartData(this.programContext, dataItem);


        }
        private void CreateDataArray(int numberOfItems)
        {
            // calculate 10 day moving average and 2*sd line

            yAxisArray = new ArrayList();
            xAxisArray = new ArrayList();

            DateTime dt = DateTime.Now;
            for (int i = 0; i < numberOfItems; ++i)
            {
                double d = i;
                yAxisArray.Add(i);
                dt = dt.AddDays(1);

                xAxisArray.Add(dt);
            }

        }
	
        [Test] 
        public void Plot_Intraday()
		{
            
            this.programContext.Configuration.IntradayModus = true;
            this.PlotShare(this.programContext.TradeEconomy.Portfolio_Selected.DataItem_Selected);

        }

       
        [Test] 
		public void Plot_Daily()
		{
                   
            this.programContext.Configuration.IntradayModus = false;
            this.PlotShare(this.programContext.TradeEconomy.Portfolio_Selected.DataItem_Selected);

		}
        private void PlotShare(IDataItem di)
        {

            chartWindow.Charts[0].DataItem = di;
            
            chartWindow.ShowDialog();
        }
        [Test]
        public void PlotShare_CandleStick()
        {

            IDataItem di = this.programContext.TradeEconomy.Portfolio_Selected.DataItem_Selected;
            
            this.programContext.TradeEconomy.Portfolio_Selected.DataItem_Selected.DataClass = di.DataClass;
            di.ID = this.DataClassFactory.StockObjectBase.ID;

            this.programContext.Configuration.IntradayModus = false;
            chartWindow.Initialize_ChartData(this.programContext, di);

            di.ChartCandleStick = true;
           
            chartWindow.ShowDialog();
        }
        [Test]
        public void PlotTradeEvents()
        {
            
            //simulate
            GridBase gridTrade;
            gridTrade = new GridBase();
            
            
            IDataClass dc = this.programContext.TradeEconomy.Portfolio_Simulation.DataItem_Selected.DataClass ;//= this.programContext.TradeEconomy.Portfolio_Selected.DataItem_Selected.DataClass;
            this.programContext.TradeEconomy.TradeSimulation.SimulationShare(this.dataItem, TradeWriteModes.EndResultShareInFile, true, false, null);
			

            
            //TradeEvents in tss.TradeStepFactory.TradeEvents
            Plot_Daily();



        }
	
	
	}
	
}